Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pointless indexsets.tabulate parameter include_data #138

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

glatterf42
Copy link
Member

Partly closes #137: this PR removes the include_data parameter, but doesn't add any way to check the length of the indexset.data. For that you still have to get the indexset somehow and access the attribute directly.

Please note that I did quickly check if including len(data) would easily be possible. I don't think it is because indexset.data is a @property on the DB model class at the moment, so not loaded automatically when using tabulate. That's because base.tabulate() uses pd.read_sql(), which only reads in the columns of the returned data model (not relationships or attributes built on them).
In contrast, e.g. base.list() returns a list of data models and their attributes can be accessed normally.
Thus, it seems to me that there's no quick way to change that for indexset.tabulate(), though it can definitely be done; either through rewriting base.tabulate() (think: SELECT all resulting rows first, load their .data, then turn into pd.DataFrame) or by accessing the DB twice (think: use base.tabulate()as usual, then use e.g.base.list()to get the.datadata and put it into a new column). Neither of those options seems desirable to me at the moment and I don't think it's necessary to comply with themessage_ix` API, so i would ignore that part of #137 for now (at least, if not forever).

@glatterf42 glatterf42 added the enhancement New feature or request label Nov 27, 2024
@glatterf42 glatterf42 self-assigned this Nov 27, 2024
Copy link

codecov bot commented Nov 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.9%. Comparing base (e252b7c) to head (bc61725).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##            main    #138     +/-   ##
=======================================
- Coverage   87.0%   86.9%   -0.1%     
=======================================
  Files        228     228             
  Lines       8155    8149      -6     
=======================================
- Hits        7095    7089      -6     
  Misses      1060    1060             
Files with missing lines Coverage Δ
ixmp4/core/optimization/indexset.py 92.6% <100.0%> (ø)
ixmp4/data/abstract/optimization/indexset.py 80.6% <100.0%> (ø)
ixmp4/data/api/optimization/indexset.py 97.6% <100.0%> (ø)
ixmp4/data/db/base.py 92.2% <ø> (-0.1%) ⬇️
ixmp4/data/db/optimization/indexset/repository.py 98.1% <100.0%> (-0.2%) ⬇️
ixmp4/server/rest/optimization/indexset.py 100.0% <ø> (ø)

@glatterf42 glatterf42 force-pushed the remove/pointless-tabulate-parameter branch 2 times, most recently from 50d6fae to 79b2c14 Compare November 29, 2024 13:23
Base automatically changed from enh/professional-grade-mypy to main December 19, 2024 11:00
@glatterf42 glatterf42 force-pushed the remove/pointless-tabulate-parameter branch from 79b2c14 to bc61725 Compare December 19, 2024 11:12
@glatterf42 glatterf42 merged commit 26abf0e into main Dec 19, 2024
13 checks passed
@glatterf42 glatterf42 deleted the remove/pointless-tabulate-parameter branch December 19, 2024 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove <OptimizationItem>.tabulate(include_data)
2 participants